package com.designpatterns.singleton;

import java.util.concurrent.TimeUnit;

/**
 * 饿汉单例模式
 * 不存在线程安全问题
 * 存在资源浪费，类家在的时候就已经创建了雷对象，即便是不使用也会常见该对象
 * Created by mike on 18/1/1.
 */
public class HungerSingleton {
    private static HungerSingleton obj = new HungerSingleton();
    private HungerSingleton(){}
    public static HungerSingleton getInstance(){
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return obj;
    }
}
